#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include "beep.h"
#include "touch.h"
#include "key.h"



void *touch_task(void *arg)
{
	int x, y;
	
	while(1)
	{
		press(&x, &y);
		
		printf("touch: (%d, %d)\n", x, y);
	}
	
	pthread_exit(NULL);
}


void *beep_task(void *arg)
{
	beep_init();
	
	while(1)
	{
		beep_on();
		sleep(1);
		
		beep_off();
		sleep(4);
	}
	
	beep_uninit();
	
	pthread_exit(NULL);
}

void *key_task(void *arg)
{
	while(1)
	{
		key_scan();
	}
	
	pthread_exit(NULL);
}

void *led_task(void *arg)
{
	
}

int main(int argc, char *argv[])
{
	pthread_t ts_tid, beep_tid, key_tid;
	
	pthread_create(&ts_tid, NULL, touch_task, NULL);
	pthread_create(&beep_tid, NULL, beep_task, NULL);
	pthread_create(&key_tid, NULL, key_task, NULL);
	
	
	pause(); // 阻塞
	
	pthread_exit(NULL);
}